capture log close
log using crisis_rep_2018common, replace text
//program:  crisis_rep_2018common.do
//task:    Replication of 2018 CCES Common Content analyses
//project: Politics of Personal Crisis (Ojeda, Michener & Haselswerdt), Political Behavior     
//author: Jake Haselswerdt \ 2024-3-7

//program setup
version 15
clear all
set linesize 80
macro drop _all
set scheme s1mono
graph set window fontface "GillSans"
set more off

use CCES2018_common_crisis_vv.dta, clear
svyset [pweight=commonweight]
global controls "voted2016_valid female black hisp other age educ income married churchattend child18_01"

//Descriptives
foreach c in crisis_income crisis_jobloss crisis_divorce crisis_victim crisis_er{
di "`: var label `c''"
svy: proportion `c'
}
svy: proportion total_crises

sum voted_valid total_crises voted2016_valid educ female black hisp other age income churchattend married child18_01 [aw=commonweight]

// Figure 1: Histogram/Frequency Distribution
graph twoway (hist total_crises, discrete percent fcolor(gs10) lcolor(white)), ///
	title("CES 2018 Common") ///
	xtitle("Count of Negative Life Events") ///
	xlabel(0(1)5, labsize(2.5)) ///
	ytitle("Percentage of Respondents") ///
	ylabel(0(10)70, labsize(2.5) angle(horizontal)) ///	
	yscale(titlegap(2)) ///
	xscale(titlegap(2)) ///
	graphregion(fcolor(white)) ///
	scheme(s1mono) graphregion(fcolor(white)) aspect(1) ///
	saving(cces18cc_hist, replace) 

// Table 2 & Appendix D: T-tests of Bivariate Association 
foreach var of varlist crisis_income crisis_jobloss crisis_divorce crisis_victim crisis_er{	
di ""
di "`:variable label `var''"
ttest voted_valid, by(`var')
di ""
}
	
// Table 3: Cross-tabulation of crisis terciles with voting
tab lomedhi_crises, sum(total_crises)
svy: tab voted_valid lomedhi_crises, col

// Table 4 & Appendix E: Logistic regressions of voting on personal crisis
svy: logit voted_valid total_crises $controls

// Table 5: Models of other participation

*Total count of non-voting participation acts
svy: reg total_part total_crises $controls

*Individual non-voting participation acts
foreach act in meeting sign work protest contact donate{
di " "
di "`:variable label part_`act''"
svy: logit part_`act' total_crises $controls
}

// Appendix F: Demographics and Crises
tab female [aw=commonweight], sum(total_crises)

gen age_cat = .
replace age_cat = 1 if age < 36
replace age_cat = 2 if age > 35
replace age_cat = 3 if age > 55
tab age_cat [aw=commonweight], sum(total_crises)
drop age_cat

gen race_new = race
recode race_new 5=4 6=4 7=4 8=4
tab race_new [aw=commonweight], sum(total_crises)
drop race_new

gen educ_degree = educ
recode educ_degree 4=4 5=4 6=4
tab educ_degree [aw=commonweight], sum(total_crises)
drop educ_degree

xtile income_quintile = income, nq(5)
tab income_quintile [aw=commonweight], sum(total_crises)
drop income_quintile

//Appendix G: Heterogeneous effects
*Dichotomous variables
foreach v in voted2016_valid female white black hisp child18_01{
di "`: var label `v''"
svy: logit voted_valid c.total_crises##i.`v' $controls
}

*Continuous/ordinal
foreach v in age income educ {
di "`: var label `v''"
svy: logit voted_valid c.total_crises##c.`v' $controls
}
log close
exit
